package configs

import (
	"strings"

	"cashew.com/cashew_common/constants"
)

var (
	// 创建用户时不支持的国家默认此国家级
	DefaultCountryCode = Manager.GetString("region.default_country_code")

	//api1站点域名
	DomainApi = Manager.GetString("domain.api")

	// 内网发送聊天消息接口
	FreeChatSendMessage = Manager.GetString("freeChatSendMessage")

	// ws和计费
	WsHttpUrl        = Manager.GetString("websocket.http_url")
	ChargingStartUrl = Manager.GetString("charging.start_url")
	ChargingStopUrl  = Manager.GetString("charging.stop_url")

	// 文件上传
	FileHost              = Manager.GetString("upload.host")
	UploadMaxSize         = Manager.GetInt64("upload.max_size")
	UploadBasePath        = Manager.GetString("upload.base_path")
	UploadFileKeyPathMap  = Manager.GetStringMapString("fileKeyPath")
	UploadFileTypePathMap = Manager.GetStringMapString("fileTypePath")

	// 业务平台(coco或maoyin)
	MasterApiHost = Manager.GetString("masterApi.host")

	// 过滤ip
	FilterIpOpen     = Manager.GetInt("filterIp.open")
	FilterIpAllowIps = Manager.GetStringSlice("filterIp.allow_ips")

	// 过滤签名
	FilterSignIsOpen = Manager.GetInt("filterSign.open")
	FilterSignKey    = Manager.GetString("filterSign.key")
	FilterWebSignKey = Manager.GetString("filterSign.key_web")

	// 过滤token(客户端token)
	FilterTokenIsOpen   = Manager.GetInt("filterToken.open")
	FilterTokenCacheKey = Manager.GetString("filterToken.cache_key")

	// 过滤服务编码
	FilterCodeIsOpen     = Manager.GetInt("filterCode.open")
	FilterCodeKey        = Manager.GetString("filterCode.key")
	FilterCodeServerName = Manager.GetString("filterCode.server_name")
	FilterCodeTimeLimit  = Manager.GetInt64("filterCode.time_limit")

	// 过滤 ServiceCode
	FilterServiceCodeIsOpen = Manager.GetInt("filterServiceCodeIsOpen")
	ServiceKeys             = Manager.GetStringMapString("serviceKeys")

	// 免费聊天次数
	ImChatFreeCount = Manager.GetString("imChat.freeCount")

	//跨域
	AllowOriginDomain = Manager.GetStringSlice("allowOrigin.domain")
	AllowOriginMethod = Manager.GetStringSlice("allowOrigin.method")
	AllowOriginHeader = Manager.GetStringSlice("allowOrigin.header")

	// 协程池
	AntsPoolMaxCocoPushWait      = Manager.GetInt("antsPool.max_coco_push_wait")
	AntsPoolMaxBalanceNoticeWait = Manager.GetInt("antsPool.max_balance_notice_wait")

	// 轮询任务
	TickerTaskQuickCallOpen         = Manager.GetInt("tickerTask.quickCallOpen")
	TickerTaskAnchorKeyPrefix       = Manager.GetString("tickerTask.anchorKeyPrefix")
	TickerTaskAnchorNewKeyPrefix    = Manager.GetString("tickerTask.anchorNewKeyPrefix")
	TickerTaskMatchedKeyPrefix      = Manager.GetString("tickerTask.matchedKeyPrefix")
	TickerTaskUserPoolKey           = Manager.GetString("tickerTask.userPoolKey")
	TickerTaskUserInfoKeyPrefix     = Manager.GetString("tickerTask.userInfoKeyPrefix")
	TickerTaskMinCoinForQuickCall   = Manager.GetInt64("tickerTask.minCoinForQuickCall")
	TickerTaskMatchedKeyExpire      = Manager.GetInt64("tickerTask.matchedKeyExpire")
	TickerTaskTimerQuickCallSeconds = Manager.GetInt64("tickerTask.timerQuickCallSeconds")
	TickerTaskUserInfoKeyExpire     = Manager.GetInt64("tickerTask.userInfoKeyExpire")
	TickerTaskAnchorKeyExpire       = Manager.GetInt64("tickerTask.anchorKeyExpire")

	//黑名单总数
	BlackListMaxCount = Manager.GetInt64("blackList.max_count")

	// 主播评级
	AnchorRatingSCalledRate            = Manager.GetInt("anchorRating.SCalledRate")
	AnchorRatingSScore                 = Manager.GetInt64("anchorRating.SScore")
	AnchorRatingSOnlineDurationMinutes = Manager.GetInt64("anchorRating.SOnlineDurationMinutes")
	AnchorRatingACalledRate            = Manager.GetInt("anchorRating.ACalledRate")
	AnchorRatingAScore                 = Manager.GetInt64("anchorRating.AScore")
	AnchorRatingAOnlineDurationMinutes = Manager.GetInt64("anchorRating.AOnlineDurationMinutes")
	AnchorRatingBNewAnchorDays         = Manager.GetInt("anchorRating.BNewAnchorDays")
	AnchorRatingDefaultRegionId        = Manager.GetInt("anchorRating.defaultRegionId")

	OffUrl = Manager.GetString("cashew_api.off_url")

	// 服务器名称
	WorkServerName = Manager.GetString("workServer.name")

	ScenesFailTime = Manager.GetInt("cashew_scenes_fail_time")

	TriggerUpdateTime = Manager.GetInt("trigger.update_time")

	// MQ_EVENT_DATA_UPDATED同步到ES的索引
	EsUserList = Manager.GetString("es_indexs.user_list")

	// 首页配置
	HomepageType    = Manager.GetString("homepage.type")
	SubRegionsCodes = Manager.GetString("homepage.sub_region_codes")

	// 当前系统的主播评级范围
	AnchorRatings = Manager.GetString("homepage.anchor_ratings")

	// 当前系统的用户标签范围
	UserTags = Manager.GetString("homepage.user_tags")

	// 用户&主播信息同步es时 获取大区,国家对应关系, 用来判断本国家, 本大区
	RegionWeight = map[string][]string{
		"MOREN": strings.SplitN(Manager.GetString("regionWeight.MOREN"), ",", 2),
		"CN":    strings.SplitN(Manager.GetString("regionWeight.CN"), ",", 2),
		"ID":    strings.SplitN(Manager.GetString("regionWeight.ID"), ",", 2),
	}

	// 用户&主播状态同步es时的权重数字
	StatusWeight = map[int]int64{
		1: Manager.GetInt64("statusWeight.1"),
		2: Manager.GetInt64("statusWeight.2"),
		3: Manager.GetInt64("statusWeight.3"),
		4: Manager.GetInt64("statusWeight.4"),
	}

	// 主播评级数字对应的字符串
	RatingStr = map[int]string{
		0: "",
		1: Manager.GetString("ratingStr.1"),
		2: Manager.GetString("ratingStr.2"),
		3: Manager.GetString("ratingStr.3"),
		4: Manager.GetString("ratingStr.4"),
	}

	// 主播评级同步es时的权重数字
	RatingWeight = map[int]int64{
		0: 0,
		1: Manager.GetInt64("ratingWeight.1"),
		2: Manager.GetInt64("ratingWeight.2"),
		3: Manager.GetInt64("ratingWeight.3"),
		4: Manager.GetInt64("ratingWeight.4"),
	}

	// 用户标签同步es时的权重数字
	TagWeight = map[string]int64{
		"RECHARGED_USER":        Manager.GetInt64("tagWeight.RECHARGED_USER"),
		"NEW_WITH_FREE_CARD":    Manager.GetInt64("tagWeight.NEW_WITH_FREE_CARD"),
		"NEW_WITHOUT_FREE_CARD": Manager.GetInt64("tagWeight.NEW_WITHOUT_FREE_CARD"),
		"OLD_USER":              Manager.GetInt64("tagWeight.OLD_USER"),
	}

	// MQ_EVENT_DATA_UPDATED需要同步到es的类型
	UserInfoSyncEsType = map[string]bool{
		constants.DATA_UPDATED_FAST_ORDER_UPDATED:       true,
		constants.DATA_UPDATED_LIVE_MODEL_UPDATED:       true,
		constants.DATA_UPDATED_DISABLE_STATUS_UPDATED:   true,
		constants.DATA_UPDATED_USER_INFO_UPDATED:        true,
		constants.DATA_UPDATED_ANCHOR_RATING_UPDATED:    true,
		constants.DATA_UPDATED_USER_TAG_UPDATED:         true,
		constants.DATA_UPDATED_USER_IDENTITY_UPDATED:    true,
		constants.DATA_UPDATED_HAVE_FREE_CARD_UPDATED:   true,
		constants.DATA_UPDATED_ANCHOR_PAY_PRICE_UPDATED: true,
		constants.DATA_UPDATED_CALL:                     true,
		constants.DATA_UPDATED_QUICK_CALL_SUCCESS:       true,
		constants.DATA_UPDATED_ANSWER_CALL:              true,
		constants.DATA_UPDATED_STOP_CALL:                true,
		constants.DATA_UPDATED_WS_CONNECT:               true,
		constants.DATA_UPDATED_WS_DISCONNECT:            true,
	}

	// 主播每日统计数字类型对应的字段名
	WorkTypeMapping = map[int]string{
		1: "OnlineTime",
		2: "IncomingCallCount",
		3: "IncomingCallAnsweredCount",
		4: "CallCount",
		5: "CallAnsweredCount",
		6: "CallIncome",
		7: "GiftIncome",
		8: "ChatUnlockCount",
	}

	// 用户首页主播各等级数量配置
	AnchorListPageConfig = map[string]map[string]int{
		constants.USER_TAG_NEW_WITH_FREE_CARD: {
			constants.ANCHOR_GRADE_S_STR: Manager.GetInt("homepage_count_user_new_with_free_card.S"),
			constants.ANCHOR_GRADE_A_STR: Manager.GetInt("homepage_count_user_new_with_free_card.A"),
			constants.ANCHOR_GRADE_B_STR: Manager.GetInt("homepage_count_user_new_with_free_card.B"),
			constants.ANCHOR_GRADE_C_STR: Manager.GetInt("homepage_count_user_new_with_free_card.C"),
		},
		constants.USER_TAG_NEW_WITHOUT_FREE_CARD: {
			constants.ANCHOR_GRADE_S_STR: Manager.GetInt("homepage_count_user_new_without_free_card.S"),
			constants.ANCHOR_GRADE_A_STR: Manager.GetInt("homepage_count_user_new_without_free_card.A"),
			constants.ANCHOR_GRADE_B_STR: Manager.GetInt("homepage_count_user_new_without_free_card.B"),
			constants.ANCHOR_GRADE_C_STR: Manager.GetInt("homepage_count_user_new_without_free_card.C"),
		},
		constants.USER_TAG_RECHARGED_USER: {
			constants.ANCHOR_GRADE_S_STR: Manager.GetInt("homepage_count_user_recharged_user.S"),
			constants.ANCHOR_GRADE_A_STR: Manager.GetInt("homepage_count_user_recharged_user.A"),
			constants.ANCHOR_GRADE_B_STR: Manager.GetInt("homepage_count_user_recharged_user.B"),
			constants.ANCHOR_GRADE_C_STR: Manager.GetInt("homepage_count_user_recharged_user.C"),
		},
		constants.USER_TAG_OLD_USER: {
			constants.ANCHOR_GRADE_S_STR: Manager.GetInt("homepage_count_user_old_user.S"),
			constants.ANCHOR_GRADE_A_STR: Manager.GetInt("homepage_count_user_old_user.A"),
			constants.ANCHOR_GRADE_B_STR: Manager.GetInt("homepage_count_user_old_user.B"),
			constants.ANCHOR_GRADE_C_STR: Manager.GetInt("homepage_count_user_old_user.C"),
		},
	}

	// 主播首页用户各标签数量配置
	UserListPageConfig = map[string]map[string]int{
		constants.ANCHOR_GRADE_S_STR: {
			constants.USER_TAG_NEW_WITH_FREE_CARD:    Manager.GetInt("homepage_count_anchor_rating_S.NEW_WITH_FREE_CARD"),
			constants.USER_TAG_NEW_WITHOUT_FREE_CARD: Manager.GetInt("homepage_count_anchor_rating_S.NEW_WITHOUT_FREE_CARD"),
			constants.USER_TAG_RECHARGED_USER:        Manager.GetInt("homepage_count_anchor_rating_S.RECHARGED_USER"),
			constants.USER_TAG_OLD_USER:              Manager.GetInt("homepage_count_anchor_rating_S.OLD_USER"),
		},
		constants.ANCHOR_GRADE_A_STR: {
			constants.USER_TAG_NEW_WITH_FREE_CARD:    Manager.GetInt("homepage_count_anchor_rating_A.NEW_WITH_FREE_CARD"),
			constants.USER_TAG_NEW_WITHOUT_FREE_CARD: Manager.GetInt("homepage_count_anchor_rating_A.NEW_WITHOUT_FREE_CARD"),
			constants.USER_TAG_RECHARGED_USER:        Manager.GetInt("homepage_count_anchor_rating_A.RECHARGED_USER"),
			constants.USER_TAG_OLD_USER:              Manager.GetInt("homepage_count_anchor_rating_A.OLD_USER"),
		},
		constants.ANCHOR_GRADE_B_STR: {
			constants.USER_TAG_NEW_WITH_FREE_CARD:    Manager.GetInt("homepage_count_anchor_rating_B.NEW_WITH_FREE_CARD"),
			constants.USER_TAG_NEW_WITHOUT_FREE_CARD: Manager.GetInt("homepage_count_anchor_rating_B.NEW_WITHOUT_FREE_CARD"),
			constants.USER_TAG_RECHARGED_USER:        Manager.GetInt("homepage_count_anchor_rating_B.RECHARGED_USER"),
			constants.USER_TAG_OLD_USER:              Manager.GetInt("homepage_count_anchor_rating_B.OLD_USER"),
		},
		constants.ANCHOR_GRADE_C_STR: {
			constants.USER_TAG_NEW_WITH_FREE_CARD:    Manager.GetInt("homepage_count_anchor_rating_C.NEW_WITH_FREE_CARD"),
			constants.USER_TAG_NEW_WITHOUT_FREE_CARD: Manager.GetInt("homepage_count_anchor_rating_C.NEW_WITHOUT_FREE_CARD"),
			constants.USER_TAG_RECHARGED_USER:        Manager.GetInt("homepage_count_anchor_rating_C.RECHARGED_USER"),
			constants.USER_TAG_OLD_USER:              Manager.GetInt("homepage_count_anchor_rating_C.OLD_USER"),
		},
	}

	// http请求返回msg
	HttpResponseMap = map[int]string{
		constants.HTTP_RESULT_SUCCESS:    "success",
		constants.HTTP_FAIL_PARAMS_ERROR: "params error",
		constants.HTTP_FAIL_SYSTEM_ERROR: "system error",
	}
)
